//
//  CompanyJobEditViewController.m
//  Btpin
//
//  Created by Vic on 2019/4/9.
//  Copyright © 2019 Vic. All rights reserved.
//

#import "CompanyJobEditViewController.h"
#import "CompanyCreatInfoCell.h"
#import "MineInfoEditViewController.h"
#import "SelcetCityViewController.h"
#import "MineInfoEditViewController.h"
#import "PMineResumeSelfDescriptionViewController.h"
#import "SelectJobCategoryViewController.h"

#import "PSWageRangePickerView.h"

@interface CompanyJobEditViewController ()<UITableViewDelegate, UITableViewDataSource, PSSingleRowViewDelegate, MineInfoEditViewControllerDelegate, SelcetCityViewControllerDelegate, PMineResumeSelfDescriptionViewControllerDelegate, SelectJobCategoryViewControllerDelegate, PSWageRangePickerViewDelegate>
{
    NSMutableArray *dataArray;
    
    UITableView *jobTableView;
    UIButton *deleteBtn;
    UIButton *okBtn;
    
//    UILabel *titleForShangLbl;
    UILabel *titleLbl;
    UIImageView *lieIconImgView;
    UIButton *yesForLieBtn;
    UIButton *noForLieBtn;
    UIView *serviceView;
    UIImageView *dujiaIconImgView;
    UIImageView *feidujiaIconImgView;
    BOOL dujiaSelectFlag;
    
    NSMutableArray *wageDataArray;
    
    NSString *minwage;
    NSString *maxwage;
    
    UIView *footerView;
}
@property (nonatomic, strong) PSSingleRowView *jobsNaturePickerView;
@property (nonatomic, strong) PSSingleRowView *jobCatsPickerView;
@property (nonatomic, strong) PSSingleRowView *educationPickerView;
@property (nonatomic, strong) PSSingleRowView *experiencePickerView;

@property (nonatomic, strong) PSWageRangePickerView *wageRangePickerView;
@end

@implementation CompanyJobEditViewController

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    if (self.jobsNaturePickerView) {
        self.jobsNaturePickerView.hidden = YES;
    }
    if (self.jobCatsPickerView) {
        self.jobCatsPickerView.hidden = YES;
    }
    if (self.educationPickerView) {
        self.educationPickerView.hidden = YES;
    }
    if (self.experiencePickerView) {
        self.experiencePickerView.hidden = YES;
    }
    if (self.wageRangePickerView) {
        self.wageRangePickerView.hidden = YES;
    }
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"修改职位信息";
    
    minwage = @"";
    maxwage = @"";
    dujiaSelectFlag = YES;
    
    [self loadDataInfo];
    [self loadDataLocation];
    [self initUI];
}
- (void)saveBtnTap {
    for (NSInteger i = 0; i < dataArray.count; i++) {
        PublicCategoryElementModel *model = dataArray[i];
        if (model.detail && model.detail.length) {
        } else {
            switch (i) {
                case 0: {
                    SVPHUDError(CompanyAlertText);
                } break;
                case 1: {
                    SVPHUDError(CompanyJobsNatureAlertText);
                } break;
                case 2: {
                    SVPHUDError(CompanyJobCatsAlertText);
                } break;
                case 3: {
                    SVPHUDError(CompanyJobDescriptionAlertText);
                } break;
                case 4: {
                    SVPHUDError(CompanyWageAlertText);
                } break;
                case 5: {
                    SVPHUDError(EducationAlertText);
                } break;
                case 6: {
                    SVPHUDError(CompanyExperienceAlertText);
                } break;
                case 7: {
                    SVPHUDError(CompanyJobAddressAlertText);
                } break;
                default:
                    break;
            }
            return;
        }
    }
    [self updateInfo];
}
- (void)updateInfo {
    SVPHUDShow;
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
    dic = [UIToolsControl getPublicParameter];
    PublicCategoryElementModel *model10 = dataArray[0];
    [dic setObject:[NSNumber numberWithInteger:[model10.id integerValue]] forKey:@"job_id"];
    [dic setObject:model10.detail forKey:@"title"];
    PublicCategoryElementModel *model11 = dataArray[1];
    [dic setObject:model11.id forKey:@"nature"];
    PublicCategoryElementModel *model12 = dataArray[2];
    [dic setObject:model12.id forKey:@"category"];
    PublicCategoryElementModel *model13 = dataArray[3];
    [dic setObject:model13.detail forKey:@"contents"];
    //    PublicCategoryElementModel *model14 = dataArray[4];
    [dic setObject:minwage forKey:@"minwage"];
    [dic setObject:maxwage forKey:@"maxwage"];
    PublicCategoryElementModel *model15 = dataArray[5];
    [dic setObject:model15.id forKey:@"education"];
    PublicCategoryElementModel *model16 = dataArray[6];
    [dic setObject:model16.id forKey:@"experience"];
    PublicCategoryElementModel *model17 = dataArray[7];
    [dic setObject:model17.id forKey:@"district"];
    [dic setObject:@"0" forKey:@"sex"];
    [dic setObject:@"0" forKey:@"age"];
    [dic setObject:@"" forKey:@"department"];
    [dic setObject:((yesForLieBtn.selected)?((dujiaSelectFlag)?@"1":@"2"):@"0") forKey:@"headhunter"];
    [dic setObject:@"1" forKey:@"amount"];
    [dic setObject:@"" forKey:@"deadline"];
//    [dic setObject:((yesForShangBtn.selected)?@"1":@"0") forKey:@"share_promote"];
//    [dic setObject:chujiaTextField.text forKey:@"share_promote_price"];
//    [dic setObject:yusuanTextField.text forKey:@"share_promote_amount"];
    
    [BaseNetManager requestWithMethod:POST path:Company_JobSave_URL params:dic successBlock:^(NSDictionary * _Nonnull responseObject) {
        if ([responseObject[@"code"] integerValue] == 2000) {
            SVPHUDSuccess(responseObject[@"msg"]);
            
            [self performSelector:@selector(delayClick) withObject:nil afterDelay:0.5];
        } else {
            SVPHUDError(responseObject[@"msg"]);
        }
    } failurBlock:^(NSError * _Nonnull error) {
        SVPHUDError(NetErrorAlertText);
    }];
}
- (void)delayClick {
    self.edit(YES);
    [self.navigationController popToRootViewControllerAnimated:YES];
}
- (void)loadDataInfo {
    [self loadDataForWage];
    
    self.jobsNaturePickerView = [[PSSingleRowView alloc] initWithData:[DataToolsControl sharedManager].allCategoryInfoModel.jobsNatureArray target:self];
    self.jobsNaturePickerView.hidden = YES;
    self.jobCatsPickerView = [[PSSingleRowView alloc] initWithData:[DataToolsControl sharedManager].allCategoryInfoModel.jobCatsArray target:self];
    self.jobCatsPickerView.hidden = YES;
    self.wageRangePickerView = [[PSWageRangePickerView alloc] initWithDataArray:wageDataArray target:self];
    self.wageRangePickerView.hidden = YES;
    
    self.educationPickerView = [[PSSingleRowView alloc] initWithData:[DataToolsControl sharedManager].allCategoryInfoModel.educationArray target:self];
    self.educationPickerView.hidden = YES;
    self.experiencePickerView = [[PSSingleRowView alloc] initWithData:[DataToolsControl sharedManager].allCategoryInfoModel.experienceArray target:self];
    self.experiencePickerView.hidden = YES;
}
- (void)initUI {
    UIButton *saveBtn = [UIToolsControl initButtonWithFrame:CGRectMake(WIDTH-50*Scale, HeightOfStatusBar+3*Scale, 50*Scale, 36) imageName:nil target:self action:@selector(saveBtnTap) title:@"保存" titleColor:THEMECOLOR_OF_ORANGE];
    saveBtn.titleLabel.font = Font(Font_15);
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:saveBtn];
    self.navigationItem.rightBarButtonItem = rightItem;
    
    footerView = [UIToolsControl initViewWithFrame:CGRectMake(0, 0, WIDTH, ([self.infoModel.headhunter isEqualToString:@"0"])?0.00001:50*Scale) backgroundColor:THEMECOLOR_OF_TEXT_cccccc];
    if (![self.infoModel.headhunter isEqualToString:@"0"]) {
        NSString *text = [NSString stringWithFormat:@"    该职位已购买 猎头%@岗位 服务", ([self.infoModel.headhunter isEqualToString:@"1"])?@"独家":@"非独家"];
        UILabel *footerLbl = [UIToolsControl initLabelWithFrame:CGRectMake(0, 10*Scale, WIDTH, 40*Scale) text:text textColor:THEMECOLOR_OF_ORANGE font:Font_12];
        footerLbl.backgroundColor = RGB(250, 225, 195);
        [footerView addSubview:footerLbl];
    }
    
    jobTableView = [UIToolsControl initTableViewWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT-HeightOfStatusBarAndNavigationBar-SIMEmojKeyBoardkBottomNOSafeArea_Height-65*Scale) target:self style:UITableViewStylePlain];
    jobTableView.rowHeight = 45*Scale;
    jobTableView.sectionHeaderHeight = 0.1;
    jobTableView.tableFooterView = [[UIView alloc] init];
    jobTableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
    [self.view addSubview:jobTableView];
    
    deleteBtn = [UIToolsControl initButtonWithFrame:CGRectMake(40*Scale, EndY(jobTableView)+10*Scale, WIDTH-80*Scale, 46*Scale) imageName:nil target:self action:@selector(deleteTap) title:@"删除该职位" titleColor:COLOR_OF_WHITE];
    deleteBtn.layer.cornerRadius = 23*Scale;
    deleteBtn.layer.masksToBounds = YES;
    deleteBtn.backgroundColor = THEMECOLOR_OF_ORANGE;
    deleteBtn.titleLabel.font = Font(Font_18);
    [self.view addSubview:deleteBtn];
}
- (void)deleteTap {
    CustomView *alertView = [[CustomView alloc] initWithTitle:@"提示" message:@"确认删除该职位" prompt:nil sureBtn:@"确定" cancleBtn:@"取消" size:150];
    alertView.resultIndex = ^(NSInteger index) { //回调---处理一系列动作
        if (index == 2) {
            [self deleteClick];
        }
    };
    [alertView showXLAlertView];
}
- (void)deleteClick {
    SVPHUDShow;
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
    dic = [UIToolsControl getPublicParameter];
    [dic setObject:self.id forKey:@"job_id"];
    [BaseNetManager requestWithMethod:POST path:Company_JobDelete_URL params:dic successBlock:^(NSDictionary * _Nonnull responseObject) {
        if ([responseObject[@"code"] integerValue] == 2000) {
            SVPHUDSuccess(responseObject[@"msg"]);
            
            self.edit(YES);
            [self performSelector:@selector(delayClick) withObject:nil afterDelay:0.5];
        } else {
            SVPHUDError(responseObject[@"msg"]);
        }
    } failurBlock:^(NSError * _Nonnull error) {
        SVPHUDError(NetErrorAlertText);
    }];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return dataArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    CompanyCreatInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:isCellID];
    if (!cell) {
        cell = [[CompanyCreatInfoCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:isCellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    
    PublicCategoryElementModel *model = dataArray[indexPath.row];
    [cell reloadDataModel:model];
    if (indexPath.row == 4) {
        [self.wageRangePickerView updateWageRangeForMinWage:minwage maxWage:maxwage];
    }
    
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    switch (indexPath.row) {
        case 0: { // 职位名称
            [self pushInfoEditVC:InfoEditTypeOfPosition];
        } break;
        case 1: { // 职位性质
            self.jobsNaturePickerView.hidden = NO;
        } break;
        case 2: { // 职位类别
            [self jumpToSelectPosition];
        } break;
        case 3: { // 职位描述
            PublicCategoryElementModel *model = dataArray[indexPath.row];
            PMineResumeSelfDescriptionViewController *PMRSDVC = [[PMineResumeSelfDescriptionViewController alloc] init];
            PMRSDVC.limitTextMaxNumber = 1000;
            PMRSDVC.titleStr = @"职位描述";
            PMRSDVC.context = (model.detail&&model.detail.length)?model.detail:@"";
            PMRSDVC.delegate = self;
            [self.navigationController pushViewController:PMRSDVC animated:YES];
        } break;
        case 4: { // 薪资待遇
            self.wageRangePickerView.hidden = NO;
        } break;
        case 5: { // 学历要求
            self.educationPickerView.hidden = NO;
        } break;
        case 6: { // 经验要求
            self.experiencePickerView.hidden = NO;
        } break;
        case 7: { // 工作地区
            SelcetCityViewController *SCVC = [[SelcetCityViewController alloc] init];
            SCVC.delegate = self;
            [self.navigationController pushViewController:SCVC animated:YES];
        } break;
        default:
            break;
    }
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return [UIToolsControl initViewWithFrame:CGRectMake(0, 0, WIDTH, 0.1) backgroundColor:COLOR_OF_CLEAR];
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 0.1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    if (![self.infoModel.headhunter isEqualToString:@"0"]) {
        return 50*Scale;
    }
    return 130*Scale;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    if (![self.infoModel.headhunter isEqualToString:@"0"]) {
        return footerView;
    } else {
        UIView *bgView = [UIToolsControl initViewWithFrame:CGRectMake(0, 0, WIDTH, 130*Scale) backgroundColor:COLOR_OF_WHITE];
        
        UIView *lineView = [UIToolsControl initViewWithFrame:CGRectMake(0, 0, WIDTH, 10*Scale) backgroundColor:THEMECOLOR_OF_GRAY];
        [bgView addSubview:lineView];
        
        CGFloat bottomY = EndY(lineView);
        
        UIImageView *lieIconImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(ScalePS(15), bottomY+ScalePS(10), ScalePS(15), ScalePS(15)) imageName:@"companyjob_lie_icon"];
        [bgView addSubview:lieIconImgView];
        UILabel *titleLbl = [UIToolsControl initLabelWithFrame:CGRectMake(EndX(lieIconImgView)+ScalePS(5), bottomY, WIDTH, 35*Scale) text:@"是否开启猎头服务？" textColor:THEMECOLOR_OF_ORANGE font:Font_15];
        [bgView addSubview:titleLbl];
        
        yesForLieBtn = [UIToolsControl initButtonWithFrame:CGRectMake(185*Scale, bottomY+5*Scale, 40*Scale, 25*Scale) imageName:nil target:self action:@selector(yesBtnTap) title:@"是" titleColor:THEMECOLOR_OF_TEXT_666666];
        yesForLieBtn.backgroundColor = COLOR_OF_WHITE;
        yesForLieBtn.titleLabel.font = Font(Font_15);
        yesForLieBtn.layer.cornerRadius = 2;
        yesForLieBtn.layer.masksToBounds = YES;
        yesForLieBtn.layer.borderWidth = lineH;
        yesForLieBtn.layer.borderColor = THEMECOLOR_OF_TEXT_666666.CGColor;
        [bgView addSubview:yesForLieBtn];
        
        noForLieBtn = [UIToolsControl initButtonWithFrame:CGRectMake(EndX(yesForLieBtn)+20*Scale, bottomY+5*Scale, 40*Scale, 25*Scale) imageName:nil target:self action:@selector(noBtnTap) title:@"否" titleColor:COLOR_OF_WHITE];
        noForLieBtn.backgroundColor = THEMECOLOR_OF_ORANGE;
        noForLieBtn.titleLabel.font = Font(Font_15);
        noForLieBtn.layer.cornerRadius = 2;
        noForLieBtn.layer.masksToBounds = YES;
        noForLieBtn.layer.borderWidth = lineH;
        noForLieBtn.layer.borderColor = THEMECOLOR_OF_ORANGE.CGColor;
        [bgView addSubview:noForLieBtn];
        
        serviceView = [UIToolsControl initViewWithFrame:CGRectMake(0, EndY(titleLbl), WIDTH, 85*Scale) backgroundColor:THEMECOLOR_OF_GRAY];
        [bgView addSubview:serviceView];
        serviceView.hidden = YES;
        dujiaIconImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(20*Scale, 15*Scale, 20*Scale, 20*Scale) imageName:@"privacysetting_main_s"];
        [serviceView addSubview:dujiaIconImgView];
        UILabel *oneLbl = [UIToolsControl initLabelWithFrame:CGRectMake(EndX(dujiaIconImgView)+15*Scale, 8*Scale, WIDTH-100*Scale, 34*Scale) text:@"独家，收费标准年薪15%" textColor:THEMECOLOR_OF_TEXT_666666 font:Font_14];
        [serviceView addSubview:oneLbl];
        UIButton *oneBtn = [UIToolsControl initButtonWithFrame:CGRectMake(0, 0, WIDTH, 42.5*Scale) imageName:nil target:self action:@selector(oneBtnTap) title:nil titleColor:nil];
        [serviceView addSubview:oneBtn];
        feidujiaIconImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(20*Scale, EndY(dujiaIconImgView)+15*Scale, 20*Scale, 20*Scale) imageName:@"privacysetting_main_n"];
        [serviceView addSubview:feidujiaIconImgView];
        UILabel *moreLbl = [UIToolsControl initLabelWithFrame:CGRectMake(EndX(dujiaIconImgView)+15*Scale, EndY(oneLbl), WIDTH-100*Scale, 34*Scale) text:@"非独家，收费标准年薪20%" textColor:THEMECOLOR_OF_TEXT_666666 font:Font_14];
        [serviceView addSubview:moreLbl];
        UIButton *moreBtn = [UIToolsControl initButtonWithFrame:CGRectMake(0, EndY(oneBtn), WIDTH, 42.5*Scale) imageName:nil target:self action:@selector(moreBtnTap) title:nil titleColor:nil];
        [serviceView addSubview:moreBtn];
        
        return bgView;
    }
}
- (void)yesBtnTap {
    [okBtn setTitle:@"发布并提交猎头服务意向" forState:UIControlStateNormal];
    yesForLieBtn.selected = YES;
    serviceView.hidden = NO;
    yesForLieBtn.backgroundColor = THEMECOLOR_OF_ORANGE;
    yesForLieBtn.layer.borderColor = COLOR_OF_CLEAR.CGColor;
    [yesForLieBtn setTitleColor:COLOR_OF_WHITE forState:UIControlStateNormal];
    noForLieBtn.backgroundColor = COLOR_OF_WHITE;
    noForLieBtn.layer.borderColor = THEMECOLOR_OF_TEXT_666666.CGColor;
    [noForLieBtn setTitleColor:THEMECOLOR_OF_TEXT_666666 forState:UIControlStateNormal];
}
- (void)noBtnTap {
    [okBtn setTitle:@"立即发布" forState:UIControlStateNormal];
    yesForLieBtn.selected = NO;
    serviceView.hidden = YES;
    yesForLieBtn.backgroundColor = COLOR_OF_WHITE;
    yesForLieBtn.layer.borderColor = THEMECOLOR_OF_TEXT_666666.CGColor;
    [yesForLieBtn setTitleColor:THEMECOLOR_OF_TEXT_666666 forState:UIControlStateNormal];
    noForLieBtn.backgroundColor = THEMECOLOR_OF_ORANGE;
    noForLieBtn.layer.borderColor = THEMECOLOR_OF_ORANGE.CGColor;
    [noForLieBtn setTitleColor:COLOR_OF_WHITE forState:UIControlStateNormal];
}
- (void)oneBtnTap {
    dujiaSelectFlag = YES;
    dujiaIconImgView.image = [UIImage imageNamed:@"privacysetting_main_s"];
    feidujiaIconImgView.image = [UIImage imageNamed:@"privacysetting_main_n"];
}
- (void)moreBtnTap {
    dujiaSelectFlag = NO;
    dujiaIconImgView.image = [UIImage imageNamed:@"privacysetting_main_n"];
    feidujiaIconImgView.image = [UIImage imageNamed:@"privacysetting_main_s"];
}

- (void)pMineResumeSelfDescriptionViewControllerBack:(NSString *)info {
    PublicCategoryElementModel *tempModel = dataArray[3];
    tempModel.detail = info;
    [dataArray replaceObjectAtIndex:3 withObject:tempModel];
    [jobTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:3 inSection:0], nil] withRowAnimation:UITableViewRowAnimationNone];
}
- (void)pushInfoEditVC:(InfoEditType)type {
    MineInfoEditViewController *MIEVC = [[MineInfoEditViewController alloc] init];
    MIEVC.type = type;
    MIEVC.delegate = self;
    switch (type) {
        case InfoEditTypeOfPosition: {
            if (self.infoModel.title) {
                MIEVC.text = self.infoModel.title;
            }
        } break;
        default:
            break;
    }
    [self.navigationController pushViewController:MIEVC animated:YES];
}
- (void)mineInfoEditViewController:(NSString *)info type:(InfoEditType)type {
    switch (type) {
        case InfoEditTypeOfPosition: {
            PublicCategoryElementModel *tempModel = dataArray[0];
            tempModel.detail = info;
            [dataArray replaceObjectAtIndex:0 withObject:tempModel];
            [jobTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:0 inSection:0], nil] withRowAnimation:UITableViewRowAnimationNone];
        } break;
        default:
            break;
    }
}
- (void)selcetCityViewControllerInfo:(NSDictionary *)dic {
    PublicCategoryElementModel *tempModel = dataArray[7];
    
    if ([[NSString stringWithFormat:@"%@", dic[@"cityid"]] integerValue] == 0) {
        tempModel.id = [NSString stringWithFormat:@"%@", dic[@"provinceid"]];
        tempModel.detail = [NSString stringWithFormat:@"%@", dic[@"province"]];
    } else {
        tempModel.id = [NSString stringWithFormat:@"%@", dic[@"cityid"]];
        tempModel.detail = [NSString stringWithFormat:@"%@-%@", dic[@"province"], dic[@"city"]];
    }
    
    [dataArray replaceObjectAtIndex:7 withObject:tempModel];
    [jobTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:7 inSection:0], nil] withRowAnimation:UITableViewRowAnimationNone];
}
- (void)psSingleRowViewCancel:(PSSingleRowView *)psSingleRowView {
    psSingleRowView.hidden = YES;
}
- (void)psSingleRowViewOk:(PublicCategoryElementModel *)model PSSingleRowView:(PSSingleRowView *)psSingleRowView {
    psSingleRowView.hidden = YES;
    if (psSingleRowView == self.jobsNaturePickerView) {
        PublicCategoryElementModel *tempModel = dataArray[1];
        tempModel.detail = model.name;
        tempModel.id = model.id;
        [dataArray replaceObjectAtIndex:1 withObject:tempModel];
        [jobTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:1 inSection:0], nil] withRowAnimation:UITableViewRowAnimationNone];
    } else if (psSingleRowView == self.jobCatsPickerView) {
        PublicCategoryElementModel *tempModel = dataArray[2];
        tempModel.detail = model.name;
        tempModel.id = model.id;
        [dataArray replaceObjectAtIndex:2 withObject:tempModel];
        [jobTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:2 inSection:0], nil] withRowAnimation:UITableViewRowAnimationNone];
    } else if (psSingleRowView == self.educationPickerView) {
        PublicCategoryElementModel *tempModel = dataArray[5];
        tempModel.detail = model.name;
        tempModel.id = model.id;
        [dataArray replaceObjectAtIndex:5 withObject:tempModel];
        [jobTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:5 inSection:0], nil] withRowAnimation:UITableViewRowAnimationNone];
    } else if (psSingleRowView == self.experiencePickerView) {
        PublicCategoryElementModel *tempModel = dataArray[6];
        tempModel.detail = model.name;
        tempModel.id = model.id;
        [dataArray replaceObjectAtIndex:6 withObject:tempModel];
        [jobTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:6 inSection:0], nil] withRowAnimation:UITableViewRowAnimationNone];
    }
}
- (void)psWageRangePickerViewCancle {
    self.wageRangePickerView.hidden = YES;
}
- (void)psWageRangePickerView:(PSWageRangePickerView *)psWageRangePickerView leftModel:(PSWageRangeModel *)leftModel rightModel:(PSWageRangeModel *)rightModel {
    psWageRangePickerView.hidden = YES;
    PublicCategoryElementModel *tempModel = dataArray[4];
    tempModel.detail = [NSString stringWithFormat:@"%@~%@", leftModel.showText, rightModel.showText];
    tempModel.id = @"";
    
    minwage = leftModel.dataText;
    maxwage = rightModel.dataText;
    [dataArray replaceObjectAtIndex:4 withObject:tempModel];
    [jobTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:4 inSection:0], nil] withRowAnimation:UITableViewRowAnimationNone];
}

- (void)loadDataLocation {
    dataArray = [NSMutableArray arrayWithCapacity:0];
    PublicCategoryElementModel *model1 = [[PublicCategoryElementModel alloc] init];
    model1.name = @"职位名称";
    if (self.infoModel.id) {
        model1.id = self.infoModel.id;
    }
    if (self.infoModel.title) {
        model1.detail = self.infoModel.title;
    }
    [dataArray addObject:model1];
    PublicCategoryElementModel *model2 = [[PublicCategoryElementModel alloc] init];
    model2.name = @"职位性质";
    if (self.infoModel.nature) {
        model2.id = self.infoModel.nature;
    }
    if (self.infoModel.nature_cn) {
        model2.detail = self.infoModel.nature_cn;
    }
    [dataArray addObject:model2];
    PublicCategoryElementModel *model3 = [[PublicCategoryElementModel alloc] init];
    model3.name = @"职位类别";
    if (self.infoModel.category) {
        model3.id = self.infoModel.category;
    }
    if (self.infoModel.category_cn) {
        model3.detail = self.infoModel.category_cn;
    }
    [dataArray addObject:model3];
    PublicCategoryElementModel *model4 = [[PublicCategoryElementModel alloc] init];
    model4.name = @"职位描述";
    if (self.infoModel.contents) {
        model4.detail = self.infoModel.contents;
    }
    [dataArray addObject:model4];
    PublicCategoryElementModel *model5 = [[PublicCategoryElementModel alloc] init];
    model5.name = @"职位待遇";
    if (self.infoModel.minwage) {
        minwage = self.infoModel.minwage;
    }
    if (self.infoModel.maxwage) {
        maxwage = self.infoModel.maxwage;
    }
    if (self.infoModel.wage_cn) {
        model5.detail = self.infoModel.wage_cn;
    }
    [dataArray addObject:model5];
    PublicCategoryElementModel *model6 = [[PublicCategoryElementModel alloc] init];
    model6.name = @"学历要求";
    if (self.infoModel.education) {
        model6.id = self.infoModel.education;
    }
    if (self.infoModel.education_cn && self.infoModel.education_cn.length) {
        model6.detail = self.infoModel.education_cn;
    } else {
        model6.detail = @"不限";
    }
    [dataArray addObject:model6];
    PublicCategoryElementModel *model7 = [[PublicCategoryElementModel alloc] init];
    model7.name = @"经验要求";
    if (self.infoModel.experience) {
        model7.id = self.infoModel.experience;
    }
    if (self.infoModel.experience_cn && self.infoModel.experience_cn.length) {
        model7.detail = self.infoModel.experience_cn;
    } else {
        model7.detail = @"不限";
    }
    [dataArray addObject:model7];
    PublicCategoryElementModel *model8 = [[PublicCategoryElementModel alloc] init];
    model8.name = @"工作地区";
    if (self.infoModel.district) {
        model8.id = self.infoModel.district;
    }
    if (self.infoModel.district_cn) {
        model8.detail = self.infoModel.district_cn;
    }
    [dataArray addObject:model8];
}
- (void)jumpToSelectPosition {
    SelectJobCategoryViewController *SJCVC = [[SelectJobCategoryViewController alloc] init];
    SJCVC.navigationItem.title = @"职位";
    SJCVC.delegate = self;
    [self.navigationController pushViewController:SJCVC animated:YES];
}
- (void)selectJobCategoryViewControllerInfo:(SelectJobCategoryModel *)model {
    PublicCategoryElementModel *tempModel = dataArray[2];
    tempModel.detail = model.threeLevelName;
    tempModel.id = model.threeLevelID;
    [dataArray replaceObjectAtIndex:2 withObject:tempModel];
    [jobTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:2 inSection:0], nil] withRowAnimation:UITableViewRowAnimationNone];
}

- (void)loadDataForWage {
    wageDataArray = [NSMutableArray arrayWithCapacity:0];
    
    NSArray *arr = [DataToolsControl wageRange];
    for (NSDictionary *dic in arr) {
        PSWageRangeModel *model = [[PSWageRangeModel alloc] init];
        [model setValuesForKeysWithDictionary:dic];
        [wageDataArray addObject:model];
    }
}
//{
//    wageDataArray = [NSMutableArray arrayWithCapacity:0];
//
//    NSArray *arr = @[@"1k", @"2k", @"3k", @"4k", @"5k", @"6k", @"7k", @"8k", @"9k", @"10k", @"11k", @"12k", @"13k", @"14k", @"15k", @"16k", @"17k", @"18k", @"19k", @"20k", @"25k", @"30k", @"35k", @"40k", @"50k", @"100k"];
//    for (NSInteger i = 0; i < arr.count; i++) {
//        PublicCategoryElementModel *model = [[PublicCategoryElementModel alloc] init];
//        model.name = arr[i];
//        [wageDataArray addObject:model];
//    }
//}

@end












/*
#import "CompanyJobEditViewController.h"
#import "CompanyCreatInfoCell.h"
#import "MineInfoEditViewController.h"
#import "SelcetCityViewController.h"
#import "MineInfoEditViewController.h"
#import "PMineResumeSelfDescriptionViewController.h"
#import "SelectJobCategoryViewController.h"

#import "PSWageRangePickerView.h"

@interface CompanyJobEditViewController ()<UITableViewDelegate, UITableViewDataSource, PSSingleRowViewDelegate, MineInfoEditViewControllerDelegate, SelcetCityViewControllerDelegate, PMineResumeSelfDescriptionViewControllerDelegate, SelectJobCategoryViewControllerDelegate, PSWageRangePickerViewDelegate>
{
    NSMutableArray *dataArray;
    
    UITableView *jobTableView;
    UIButton *deleteBtn;
    UIButton *okBtn;
    
    UILabel *titleForShangLbl;
    UILabel *titleLbl;
    UIImageView *lieIconImgView;
    UIButton *yesForLieBtn;
    UIButton *noForLieBtn;
    UIView *serviceView;
    UIImageView *dujiaIconImgView;
    UIImageView *feidujiaIconImgView;
    BOOL dujiaSelectFlag;
    
    NSMutableArray *wageDataArray;
    
    NSString *minwage;
    NSString *maxwage;
    
    UIView *footerView;
}
@property (nonatomic, strong) PSSingleRowView *jobsNaturePickerView;
@property (nonatomic, strong) PSSingleRowView *jobCatsPickerView;
@property (nonatomic, strong) PSSingleRowView *educationPickerView;
@property (nonatomic, strong) PSSingleRowView *experiencePickerView;

@property (nonatomic, strong) PSWageRangePickerView *wageRangePickerView;
@end

@implementation CompanyJobEditViewController

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    if (self.jobsNaturePickerView) {
        self.jobsNaturePickerView.hidden = YES;
    }
    if (self.jobCatsPickerView) {
        self.jobCatsPickerView.hidden = YES;
    }
    if (self.educationPickerView) {
        self.educationPickerView.hidden = YES;
    }
    if (self.experiencePickerView) {
        self.experiencePickerView.hidden = YES;
    }
    if (self.wageRangePickerView) {
        self.wageRangePickerView.hidden = YES;
    }
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"修改职位信息";
    
    minwage = @"";
    maxwage = @"";
    dujiaSelectFlag = YES;
    
    [self loadDataInfo];
    [self loadDataLocation];
    [self initUI];
}
- (void)saveBtnTap {
    for (NSInteger i = 0; i < dataArray.count; i++) {
        PublicCategoryElementModel *model = dataArray[i];
        if (model.detail && model.detail.length) {
        } else {
            switch (i) {
                case 0: {
                    SVPHUDError(CompanyAlertText);
                } break;
                case 1: {
                    SVPHUDError(CompanyJobsNatureAlertText);
                } break;
                case 2: {
                    SVPHUDError(CompanyJobCatsAlertText);
                } break;
                case 3: {
                    SVPHUDError(CompanyJobDescriptionAlertText);
                } break;
                case 4: {
                    SVPHUDError(CompanyWageAlertText);
                } break;
                case 5: {
                    SVPHUDError(EducationAlertText);
                } break;
                case 6: {
                    SVPHUDError(CompanyExperienceAlertText);
                } break;
                case 7: {
                    SVPHUDError(CompanyJobAddressAlertText);
                } break;
                default:
                    break;
            }
            return;
        }
    }
    [self updateInfo];
}
- (void)updateInfo {
    SVPHUDShow;
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
    dic = [UIToolsControl getPublicParameter];
    PublicCategoryElementModel *model10 = dataArray[0];
    [dic setObject:[NSNumber numberWithInteger:[model10.id integerValue]] forKey:@"job_id"];
    [dic setObject:model10.detail forKey:@"title"];
    PublicCategoryElementModel *model11 = dataArray[1];
    [dic setObject:model11.id forKey:@"nature"];
    PublicCategoryElementModel *model12 = dataArray[2];
    [dic setObject:model12.id forKey:@"category"];
    PublicCategoryElementModel *model13 = dataArray[3];
    [dic setObject:model13.detail forKey:@"contents"];
//    PublicCategoryElementModel *model14 = dataArray[4];
    [dic setObject:minwage forKey:@"minwage"];
    [dic setObject:maxwage forKey:@"maxwage"];
    PublicCategoryElementModel *model15 = dataArray[5];
    [dic setObject:model15.id forKey:@"education"];
    PublicCategoryElementModel *model16 = dataArray[6];
    [dic setObject:model16.id forKey:@"experience"];
    PublicCategoryElementModel *model17 = dataArray[7];
    [dic setObject:model17.id forKey:@"district"];
    [dic setObject:@"0" forKey:@"sex"];
    [dic setObject:@"0" forKey:@"age"];
    [dic setObject:@"" forKey:@"department"];
    [dic setObject:((yesForLieBtn.selected)?((dujiaSelectFlag)?@"1":@"2"):@"0") forKey:@"headhunter"];
    [dic setObject:@"1" forKey:@"amount"];
    [dic setObject:@"" forKey:@"deadline"];
//    [dic setObject:((yesForShangBtn.selected)?@"1":@"0") forKey:@"share_promote"];
//    [dic setObject:chujiaTextField.text forKey:@"share_promote_price"];
//    [dic setObject:yusuanTextField.text forKey:@"share_promote_amount"];
    
    [BaseNetManager requestWithMethod:POST path:Company_JobSave_URL params:dic successBlock:^(NSDictionary * _Nonnull responseObject) {
        if ([responseObject[@"code"] integerValue] == 2000) {
            SVPHUDSuccess(responseObject[@"msg"]);
            
            [self performSelector:@selector(delayClick) withObject:nil afterDelay:0.5];
        } else {
            SVPHUDError(responseObject[@"msg"]);
        }
    } failurBlock:^(NSError * _Nonnull error) {
        SVPHUDError(NetErrorAlertText);
    }];
}
- (void)delayClick {
    self.edit(YES);
    [self.navigationController popToRootViewControllerAnimated:YES];
}
- (void)loadDataInfo {
    [self loadDataForWage];
    
    self.jobsNaturePickerView = [[PSSingleRowView alloc] initWithData:[DataToolsControl sharedManager].allCategoryInfoModel.jobsNatureArray target:self];
    self.jobsNaturePickerView.hidden = YES;
    self.jobCatsPickerView = [[PSSingleRowView alloc] initWithData:[DataToolsControl sharedManager].allCategoryInfoModel.jobCatsArray target:self];
    self.jobCatsPickerView.hidden = YES;
    self.wageRangePickerView = [[PSWageRangePickerView alloc] initWithDataArray:wageDataArray target:self];
    self.wageRangePickerView.hidden = YES;
    
    self.educationPickerView = [[PSSingleRowView alloc] initWithData:[DataToolsControl sharedManager].allCategoryInfoModel.educationArray target:self];
    self.educationPickerView.hidden = YES;
    self.experiencePickerView = [[PSSingleRowView alloc] initWithData:[DataToolsControl sharedManager].allCategoryInfoModel.experienceArray target:self];
    self.experiencePickerView.hidden = YES;
}
- (void)initUI {
    UIButton *saveBtn = [UIToolsControl initButtonWithFrame:CGRectMake(WIDTH-50*Scale, HeightOfStatusBar+3*Scale, 50*Scale, 36) imageName:nil target:self action:@selector(saveBtnTap) title:@"保存" titleColor:THEMECOLOR_OF_ORANGE];
    saveBtn.titleLabel.font = Font(Font_15);
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:saveBtn];
    self.navigationItem.rightBarButtonItem = rightItem;
    
    footerView = [UIToolsControl initViewWithFrame:CGRectMake(0, 0, WIDTH, ([self.infoModel.headhunter isEqualToString:@"0"])?0.00001:50*Scale) backgroundColor:THEMECOLOR_OF_TEXT_cccccc];
    if (![self.infoModel.headhunter isEqualToString:@"0"]) {
        NSString *text = [NSString stringWithFormat:@"    该职位已购买 猎头%@岗位 服务", ([self.infoModel.headhunter isEqualToString:@"1"])?@"独家":@"非独家"];
        UILabel *footerLbl = [UIToolsControl initLabelWithFrame:CGRectMake(0, 10*Scale, WIDTH, 40*Scale) text:text textColor:THEMECOLOR_OF_ORANGE font:Font_12];
        footerLbl.backgroundColor = RGB(250, 225, 195);
        [footerView addSubview:footerLbl];
    }
    
    jobTableView = [UIToolsControl initTableViewWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT-HeightOfStatusBarAndNavigationBar-HeightOfTabBarSafeMargin-65*Scale) target:self style:UITableViewStylePlain];
    jobTableView.rowHeight = 45*Scale;
    jobTableView.sectionHeaderHeight = 0.1;
    jobTableView.tableFooterView = [[UIView alloc] init];
    jobTableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
    [self.view addSubview:jobTableView];
    
    deleteBtn = [UIToolsControl initButtonWithFrame:CGRectMake(40*Scale, EndY(jobTableView)+10*Scale, WIDTH-80*Scale, 46*Scale) imageName:nil target:self action:@selector(deleteTap) title:@"删除该职位" titleColor:COLOR_OF_WHITE];
    deleteBtn.layer.cornerRadius = 23*Scale;
    deleteBtn.layer.masksToBounds = YES;
    deleteBtn.backgroundColor = THEMECOLOR_OF_ORANGE;
    deleteBtn.titleLabel.font = Font(Font_18);
    [self.view addSubview:deleteBtn];
}
- (void)deleteTap {
    CustomView *alertView = [[CustomView alloc] initWithTitle:@"提示" message:@"确认删除该职位" prompt:nil sureBtn:@"确定" cancleBtn:@"取消" size:150];
    alertView.resultIndex = ^(NSInteger index) { //回调---处理一系列动作
        if (index == 2) {
            [self deleteClick];
        }
    };
    [alertView showXLAlertView];
}
- (void)deleteClick {
    SVPHUDShow;
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
    dic = [UIToolsControl getPublicParameter];
    [dic setObject:self.id forKey:@"job_id"];
    [BaseNetManager requestWithMethod:POST path:Company_JobDelete_URL params:dic successBlock:^(NSDictionary * _Nonnull responseObject) {
        if ([responseObject[@"code"] integerValue] == 2000) {
            SVPHUDSuccess(responseObject[@"msg"]);
            
            self.edit(YES);
            [self performSelector:@selector(delayClick) withObject:nil afterDelay:0.5];
        } else {
            SVPHUDError(responseObject[@"msg"]);
        }
    } failurBlock:^(NSError * _Nonnull error) {
        SVPHUDError(NetErrorAlertText);
    }];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return dataArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    CompanyCreatInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:isCellID];
    if (!cell) {
        cell = [[CompanyCreatInfoCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:isCellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    
    PublicCategoryElementModel *model = dataArray[indexPath.row];
    [cell reloadDataModel:model];
    if (indexPath.row == 4) {
        [self.wageRangePickerView updateWageRangeForMinWage:minwage maxWage:maxwage];
    }
    
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    switch (indexPath.row) {
        case 0: { // 职位名称
            [self pushInfoEditVC:InfoEditTypeOfPosition];
        } break;
        case 1: { // 职位性质
            self.jobsNaturePickerView.hidden = NO;
        } break;
        case 2: { // 职位类别
            [self jumpToSelectPosition];
        } break;
        case 3: { // 职位描述
            PublicCategoryElementModel *model = dataArray[indexPath.row];
            PMineResumeSelfDescriptionViewController *PMRSDVC = [[PMineResumeSelfDescriptionViewController alloc] init];
            PMRSDVC.limitTextMaxNumber = 1000;
            PMRSDVC.titleStr = @"职位描述";
            PMRSDVC.context = (model.detail&&model.detail.length)?model.detail:@"";
            PMRSDVC.delegate = self;
            [self.navigationController pushViewController:PMRSDVC animated:YES];
        } break;
        case 4: { // 薪资待遇
            self.wageRangePickerView.hidden = NO;
        } break;
        case 5: { // 学历要求
            self.educationPickerView.hidden = NO;
        } break;
        case 6: { // 经验要求
            self.experiencePickerView.hidden = NO;
        } break;
        case 7: { // 工作地区
            SelcetCityViewController *SCVC = [[SelcetCityViewController alloc] init];
            SCVC.delegate = self;
            [self.navigationController pushViewController:SCVC animated:YES];
        } break;
        default:
            break;
    }
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return [UIToolsControl initViewWithFrame:CGRectMake(0, 0, WIDTH, 0.1) backgroundColor:COLOR_OF_CLEAR];
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 0.1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    if (![self.infoModel.headhunter isEqualToString:@"0"]) {
        return 50*Scale;
    }
    return 130*Scale;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    if (![self.infoModel.headhunter isEqualToString:@"0"]) {
        return footerView;
    } else {
        UIView *bgView = [UIToolsControl initViewWithFrame:CGRectMake(0, 0, WIDTH, 130*Scale) backgroundColor:COLOR_OF_WHITE];
        
        UIView *lineView = [UIToolsControl initViewWithFrame:CGRectMake(0, 0, WIDTH, 10*Scale) backgroundColor:THEMECOLOR_OF_GRAY];
        [bgView addSubview:lineView];
        
        CGFloat bottomY = EndY(lineView);
        if ([self.infoModel.promote_status integerValue] == 1) {
            titleForShangLbl = [UIToolsControl initLabelWithFrame:CGRectMake(0, EndY(lineView), WIDTH, 35*Scale) text:@"        该职位已发布推广悬赏" textColor:THEMECOLOR_OF_ORANGE font:Font_15];
            titleForShangLbl.userInteractionEnabled = YES;
            titleForShangLbl.backgroundColor = COLOR_OF_WHITE;
            [titleForShangLbl borderColor:THEMECOLOR_OF_TEXT_cccccc borderWidth:lineH borderType:BorderSideTypeBottom];
            [bgView addSubview:titleForShangLbl];
            NSString *alertUp1 = @"        该职位已发布推广悬赏";
            NSString *alertUp2 = @"        该职位已发布";
            NSMutableAttributedString *alertUpAtt = [[NSMutableAttributedString alloc] initWithString:alertUp1];
            [alertUpAtt addAttributes:@{NSFontAttributeName:Font(Font_15), NSForegroundColorAttributeName:THEMECOLOR_OF_RED} range:NSMakeRange(0, alertUp1.length)];
            [alertUpAtt addAttributes:@{NSFontAttributeName:Font(Font_15), NSForegroundColorAttributeName:THEMECOLOR_OF_TEXT_666666} range:NSMakeRange(0, alertUp2.length)];
            titleForShangLbl.attributedText = alertUpAtt;
            
            UIImageView *shangIconImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(ScalePS(15), EndY(lineView)+ScalePS(11), ScalePS(12), ScalePS(12)) imageName:@"companyjob_shang_small_icon"];
            [bgView addSubview:shangIconImgView];
            
            bottomY = EndY(titleForShangLbl)+1;
        }
        
        UIImageView *lieIconImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(ScalePS(15), bottomY+ScalePS(11), ScalePS(12), ScalePS(12)) imageName:@"companyjob_lie_icon"];
        [bgView addSubview:lieIconImgView];
        UILabel *titleLbl = [UIToolsControl initLabelWithFrame:CGRectMake(EndX(lieIconImgView)+ScalePS(5), bottomY, WIDTH, 35*Scale) text:@"是否开启猎头服务？" textColor:THEMECOLOR_OF_ORANGE font:Font_15];
        [bgView addSubview:titleLbl];
        
        yesForLieBtn = [UIToolsControl initButtonWithFrame:CGRectMake(185*Scale, bottomY+5*Scale, 40*Scale, 25*Scale) imageName:nil target:self action:@selector(yesBtnTap) title:@"是" titleColor:THEMECOLOR_OF_TEXT_666666];
        yesForLieBtn.backgroundColor = COLOR_OF_WHITE;
        yesForLieBtn.titleLabel.font = Font(Font_15);
        yesForLieBtn.layer.cornerRadius = 2;
        yesForLieBtn.layer.masksToBounds = YES;
        yesForLieBtn.layer.borderWidth = lineH;
        yesForLieBtn.layer.borderColor = THEMECOLOR_OF_TEXT_666666.CGColor;
        [bgView addSubview:yesForLieBtn];
        
        noForLieBtn = [UIToolsControl initButtonWithFrame:CGRectMake(EndX(yesForLieBtn)+20*Scale, bottomY+5*Scale, 40*Scale, 25*Scale) imageName:nil target:self action:@selector(noBtnTap) title:@"否" titleColor:COLOR_OF_WHITE];
        noForLieBtn.backgroundColor = THEMECOLOR_OF_ORANGE;
        noForLieBtn.titleLabel.font = Font(Font_15);
        noForLieBtn.layer.cornerRadius = 2;
        noForLieBtn.layer.masksToBounds = YES;
        noForLieBtn.layer.borderWidth = lineH;
        noForLieBtn.layer.borderColor = THEMECOLOR_OF_ORANGE.CGColor;
        [bgView addSubview:noForLieBtn];
        
        serviceView = [UIToolsControl initViewWithFrame:CGRectMake(0, EndY(titleLbl), WIDTH, 85*Scale) backgroundColor:THEMECOLOR_OF_GRAY];
        [bgView addSubview:serviceView];
        serviceView.hidden = YES;
        dujiaIconImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(20*Scale, 15*Scale, 20*Scale, 20*Scale) imageName:@"privacysetting_main_s"];
        [serviceView addSubview:dujiaIconImgView];
        UILabel *oneLbl = [UIToolsControl initLabelWithFrame:CGRectMake(EndX(dujiaIconImgView)+15*Scale, 8*Scale, WIDTH-100*Scale, 34*Scale) text:@"独家，收费标准年薪15%" textColor:THEMECOLOR_OF_TEXT_666666 font:Font_14];
        [serviceView addSubview:oneLbl];
        UIButton *oneBtn = [UIToolsControl initButtonWithFrame:CGRectMake(0, 0, WIDTH, 42.5*Scale) imageName:nil target:self action:@selector(oneBtnTap) title:nil titleColor:nil];
        [serviceView addSubview:oneBtn];
        feidujiaIconImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(20*Scale, EndY(dujiaIconImgView)+15*Scale, 20*Scale, 20*Scale) imageName:@"privacysetting_main_n"];
        [serviceView addSubview:feidujiaIconImgView];
        UILabel *moreLbl = [UIToolsControl initLabelWithFrame:CGRectMake(EndX(dujiaIconImgView)+15*Scale, EndY(oneLbl), WIDTH-100*Scale, 34*Scale) text:@"非独家，收费标准年薪20%" textColor:THEMECOLOR_OF_TEXT_666666 font:Font_14];
        [serviceView addSubview:moreLbl];
        UIButton *moreBtn = [UIToolsControl initButtonWithFrame:CGRectMake(0, EndY(oneBtn), WIDTH, 42.5*Scale) imageName:nil target:self action:@selector(moreBtnTap) title:nil titleColor:nil];
        [serviceView addSubview:moreBtn];
        
        return bgView;
    }
}
- (void)yesBtnTap {
    [okBtn setTitle:@"发布并提交猎头服务意向" forState:UIControlStateNormal];
    yesForLieBtn.selected = YES;
    serviceView.hidden = NO;
    yesForLieBtn.backgroundColor = THEMECOLOR_OF_ORANGE;
    yesForLieBtn.layer.borderColor = COLOR_OF_CLEAR.CGColor;
    [yesForLieBtn setTitleColor:COLOR_OF_WHITE forState:UIControlStateNormal];
    noForLieBtn.backgroundColor = COLOR_OF_WHITE;
    noForLieBtn.layer.borderColor = THEMECOLOR_OF_TEXT_666666.CGColor;
    [noForLieBtn setTitleColor:THEMECOLOR_OF_TEXT_666666 forState:UIControlStateNormal];
}
- (void)noBtnTap {
    [okBtn setTitle:@"立即发布" forState:UIControlStateNormal];
    yesForLieBtn.selected = NO;
    serviceView.hidden = YES;
    yesForLieBtn.backgroundColor = COLOR_OF_WHITE;
    yesForLieBtn.layer.borderColor = THEMECOLOR_OF_TEXT_666666.CGColor;
    [yesForLieBtn setTitleColor:THEMECOLOR_OF_TEXT_666666 forState:UIControlStateNormal];
    noForLieBtn.backgroundColor = THEMECOLOR_OF_ORANGE;
    noForLieBtn.layer.borderColor = THEMECOLOR_OF_ORANGE.CGColor;
    [noForLieBtn setTitleColor:COLOR_OF_WHITE forState:UIControlStateNormal];
}
- (void)oneBtnTap {
    dujiaSelectFlag = YES;
    dujiaIconImgView.image = [UIImage imageNamed:@"privacysetting_main_s"];
    feidujiaIconImgView.image = [UIImage imageNamed:@"privacysetting_main_n"];
}
- (void)moreBtnTap {
    dujiaSelectFlag = NO;
    dujiaIconImgView.image = [UIImage imageNamed:@"privacysetting_main_n"];
    feidujiaIconImgView.image = [UIImage imageNamed:@"privacysetting_main_s"];
}

- (void)pMineResumeSelfDescriptionViewControllerBack:(NSString *)info {
    PublicCategoryElementModel *tempModel = dataArray[3];
    tempModel.detail = info;
    [dataArray replaceObjectAtIndex:3 withObject:tempModel];
    [jobTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:3 inSection:0], nil] withRowAnimation:UITableViewRowAnimationNone];
}
- (void)pushInfoEditVC:(InfoEditType)type {
    MineInfoEditViewController *MIEVC = [[MineInfoEditViewController alloc] init];
    MIEVC.type = type;
    MIEVC.delegate = self;
    switch (type) {
        case InfoEditTypeOfPosition: {
            if (self.infoModel.title) {
                MIEVC.text = self.infoModel.title;
            }
        } break;
        default:
            break;
    }
    [self.navigationController pushViewController:MIEVC animated:YES];
}
- (void)mineInfoEditViewController:(NSString *)info type:(InfoEditType)type {
    switch (type) {
        case InfoEditTypeOfPosition: {
            PublicCategoryElementModel *tempModel = dataArray[0];
            tempModel.detail = info;
            [dataArray replaceObjectAtIndex:0 withObject:tempModel];
            [jobTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:0 inSection:0], nil] withRowAnimation:UITableViewRowAnimationNone];
        } break;
        default:
            break;
    }
}
- (void)selcetCityViewControllerInfo:(NSDictionary *)dic {
    PublicCategoryElementModel *tempModel = dataArray[7];
    
    if ([[NSString stringWithFormat:@"%@", dic[@"cityid"]] integerValue] == 0) {
        tempModel.id = [NSString stringWithFormat:@"%@", dic[@"provinceid"]];
        tempModel.detail = [NSString stringWithFormat:@"%@", dic[@"province"]];
    } else {
        tempModel.id = [NSString stringWithFormat:@"%@", dic[@"cityid"]];
        tempModel.detail = [NSString stringWithFormat:@"%@-%@", dic[@"province"], dic[@"city"]];
    }
    
    [dataArray replaceObjectAtIndex:7 withObject:tempModel];
    [jobTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:7 inSection:0], nil] withRowAnimation:UITableViewRowAnimationNone];
}
- (void)psSingleRowViewCancel:(PSSingleRowView *)psSingleRowView {
    psSingleRowView.hidden = YES;
}
- (void)psSingleRowViewOk:(PublicCategoryElementModel *)model PSSingleRowView:(PSSingleRowView *)psSingleRowView {
    psSingleRowView.hidden = YES;
    if (psSingleRowView == self.jobsNaturePickerView) {
        PublicCategoryElementModel *tempModel = dataArray[1];
        tempModel.detail = model.name;
        tempModel.id = model.id;
        [dataArray replaceObjectAtIndex:1 withObject:tempModel];
        [jobTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:1 inSection:0], nil] withRowAnimation:UITableViewRowAnimationNone];
    } else if (psSingleRowView == self.jobCatsPickerView) {
        PublicCategoryElementModel *tempModel = dataArray[2];
        tempModel.detail = model.name;
        tempModel.id = model.id;
        [dataArray replaceObjectAtIndex:2 withObject:tempModel];
        [jobTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:2 inSection:0], nil] withRowAnimation:UITableViewRowAnimationNone];
    } else if (psSingleRowView == self.educationPickerView) {
        PublicCategoryElementModel *tempModel = dataArray[5];
        tempModel.detail = model.name;
        tempModel.id = model.id;
        [dataArray replaceObjectAtIndex:5 withObject:tempModel];
        [jobTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:5 inSection:0], nil] withRowAnimation:UITableViewRowAnimationNone];
    } else if (psSingleRowView == self.experiencePickerView) {
        PublicCategoryElementModel *tempModel = dataArray[6];
        tempModel.detail = model.name;
        tempModel.id = model.id;
        [dataArray replaceObjectAtIndex:6 withObject:tempModel];
        [jobTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:6 inSection:0], nil] withRowAnimation:UITableViewRowAnimationNone];
    }
}
- (void)psWageRangePickerViewCancle {
    self.wageRangePickerView.hidden = YES;
}
- (void)psWageRangePickerView:(PSWageRangePickerView *)psWageRangePickerView leftModel:(PSWageRangeModel *)leftModel rightModel:(PSWageRangeModel *)rightModel {
    psWageRangePickerView.hidden = YES;
    PublicCategoryElementModel *tempModel = dataArray[4];
    tempModel.detail = [NSString stringWithFormat:@"%@~%@", leftModel.showText, rightModel.showText];
    tempModel.id = @"";
    
    minwage = leftModel.dataText;
    maxwage = rightModel.dataText;
    [dataArray replaceObjectAtIndex:4 withObject:tempModel];
    [jobTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:4 inSection:0], nil] withRowAnimation:UITableViewRowAnimationNone];
}

- (void)loadDataLocation {
    dataArray = [NSMutableArray arrayWithCapacity:0];
    PublicCategoryElementModel *model1 = [[PublicCategoryElementModel alloc] init];
    model1.name = @"职位名称";
    if (self.infoModel.id) {
        model1.id = self.infoModel.id;
    }
    if (self.infoModel.title) {
        model1.detail = self.infoModel.title;
    }
    [dataArray addObject:model1];
    PublicCategoryElementModel *model2 = [[PublicCategoryElementModel alloc] init];
    model2.name = @"职位性质";
    if (self.infoModel.nature) {
        model2.id = self.infoModel.nature;
    }
    if (self.infoModel.nature_cn) {
        model2.detail = self.infoModel.nature_cn;
    }
    [dataArray addObject:model2];
    PublicCategoryElementModel *model3 = [[PublicCategoryElementModel alloc] init];
    model3.name = @"职位类别";
    if (self.infoModel.category) {
        model3.id = self.infoModel.category;
    }
    if (self.infoModel.category_cn) {
        model3.detail = self.infoModel.category_cn;
    }
    [dataArray addObject:model3];
    PublicCategoryElementModel *model4 = [[PublicCategoryElementModel alloc] init];
    model4.name = @"职位描述";
    if (self.infoModel.contents) {
        model4.detail = self.infoModel.contents;
    }
    [dataArray addObject:model4];
    PublicCategoryElementModel *model5 = [[PublicCategoryElementModel alloc] init];
    model5.name = @"职位待遇";
    if (self.infoModel.minwage) {
        minwage = self.infoModel.minwage;
    }
    if (self.infoModel.maxwage) {
        maxwage = self.infoModel.maxwage;
    }
    if (self.infoModel.wage_cn) {
        model5.detail = self.infoModel.wage_cn;
    }
    [dataArray addObject:model5];
    PublicCategoryElementModel *model6 = [[PublicCategoryElementModel alloc] init];
    model6.name = @"学历要求";
    if (self.infoModel.education) {
        model6.id = self.infoModel.education;
    }
    if (self.infoModel.education_cn && self.infoModel.education_cn.length) {
        model6.detail = self.infoModel.education_cn;
    } else {
        model6.detail = @"不限";
    }
    [dataArray addObject:model6];
    PublicCategoryElementModel *model7 = [[PublicCategoryElementModel alloc] init];
    model7.name = @"经验要求";
    if (self.infoModel.experience) {
        model7.id = self.infoModel.experience;
    }
    if (self.infoModel.experience_cn && self.infoModel.experience_cn.length) {
        model7.detail = self.infoModel.experience_cn;
    } else {
        model7.detail = @"不限";
    }
    [dataArray addObject:model7];
    PublicCategoryElementModel *model8 = [[PublicCategoryElementModel alloc] init];
    model8.name = @"工作地区";
    if (self.infoModel.district) {
        model8.id = self.infoModel.district;
    }
    if (self.infoModel.district_cn) {
        model8.detail = self.infoModel.district_cn;
    }
    [dataArray addObject:model8];
}
- (void)jumpToSelectPosition {
    SelectJobCategoryViewController *SJCVC = [[SelectJobCategoryViewController alloc] init];
    SJCVC.navigationItem.title = @"职位";
    SJCVC.delegate = self;
    [self.navigationController pushViewController:SJCVC animated:YES];
}
- (void)selectJobCategoryViewControllerInfo:(SelectJobCategoryModel *)model {
    PublicCategoryElementModel *tempModel = dataArray[2];
    tempModel.detail = model.threeLevelName;
    tempModel.id = model.threeLevelID;
    [dataArray replaceObjectAtIndex:2 withObject:tempModel];
    [jobTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:2 inSection:0], nil] withRowAnimation:UITableViewRowAnimationNone];
}

- (void)loadDataForWage {
    wageDataArray = [NSMutableArray arrayWithCapacity:0];
    
    NSArray *arr = [DataToolsControl wageRange];
    for (NSDictionary *dic in arr) {
        PSWageRangeModel *model = [[PSWageRangeModel alloc] init];
        [model setValuesForKeysWithDictionary:dic];
        [wageDataArray addObject:model];
    }
}
//{
//    wageDataArray = [NSMutableArray arrayWithCapacity:0];
//    
//    NSArray *arr = @[@"1k", @"2k", @"3k", @"4k", @"5k", @"6k", @"7k", @"8k", @"9k", @"10k", @"11k", @"12k", @"13k", @"14k", @"15k", @"16k", @"17k", @"18k", @"19k", @"20k", @"25k", @"30k", @"35k", @"40k", @"50k", @"100k"];
//    for (NSInteger i = 0; i < arr.count; i++) {
//        PublicCategoryElementModel *model = [[PublicCategoryElementModel alloc] init];
//        model.name = arr[i];
//        [wageDataArray addObject:model];
//    }
//}

@end
*/
